


import { AIServer, characterServer, MoveServer, scenceServer, SkillServer, SkinServer } from "./serverLib";



/** 场景服务 */


/* 加载场景事件 */
scenceServer.onLoadScence(scenceEntity => {
    /* 场景实体 */
    if (scenceEntity.scenceInstance && scenceEntity.config?.areas) {
        scenceEntity.aiConfigs = AIServer.initAI({
            scenceInstance: scenceEntity.scenceInstance,
            monster: scenceEntity.config.areas
        });//刷新场景里的AI

        scenceEntity.aiConfigs.forEach(c => {
            if (c.character) {
                MoveServer.addForces(c)// 添加NPC力学
                SkillServer.addCharacter(c.character)
                SkinServer.generateAccsForCharacter(c);
                AIServer.setNetWork(c.character)
            }

        })
    }

    scenceServer.syncCurrentScenceEntity();//  同步场景
    const players = game.GetService('Players').GetPlayers();
    if (players.size() > 0)
        characterServer?.loadCharacter({
            player: players[0],
            animGroup: "C1",
            bonePath: "M4",
            skinPath: "M4",
            maxJumpTimes: 2,
            jumpTimes: 0
        });//加载玩家角色 以后需要修改为玩家选择角色
})
